
function modifyPassword() {
	openDiv("password_container");
	openDiv("mask");
}
//初始化文本框的事件
function initEvent(type) {
	var allInput = document.getElementsByTagName("input");
	for (var i = 0; i < allInput.length; i++) {
		if (allInput[i].type == "text" || allInput[i].type == "password") {
			if (window.addEventListener) { // Mozilla, Netscape, Firefox   
				allInput[i].addEventListener("focus", fieldFocus, false);
				allInput[i].addEventListener("blur", fieldBlur, false);
			} else { // IE   
				allInput[i].attachEvent("onfocus", fieldFocus);
				allInput[i].attachEvent("onblur", fieldBlur);
			}
		}
	}
}
//得到焦点的事件
function fieldFocus() {
	var serE = event.srcElement;
	serE.style.backgroundColor = "white";
}
//失去焦点的事件
function fieldBlur() {
	var serE = event.srcElement;
	serE.style.backgroundColor = "#999999";
}

//检查两次输入密码是否一致
function checkPassword() {
	var newPassword = document.getElementById("newPassword");
	var reNewPassword = document.getElementById("reNewPassword");
	if (newPassword.value != reNewPassword.value) {
		document.getElementById("passwordTip").innerHTML = "\u4e24\u6b21\u8f93\u5165\u7684\u5bc6\u7801\u4e0d\u4e00\u81f4";
		return false;
	}
	return true;
}
//关闭修改密码div
function closePassword(id) {
	closediv(id);
	document.passwordForm.reset();
	document.informForm.reset();
	document.getElementById("passwordTip").innerHTML = "";
}
//打开修改个人信息div
function modifyInfo() {
	openDiv("infor_container");
	openDiv("mask");
}
function checkUser(type)
{
	if(type=='0')
	{
		return checkStudent();
	}else if(type == '1')
	{
		return checkTeacher();
	}
}
function checkStudent() {
	var sTop = document.getElementById("inforTip");
	//手机
	var sTelephone = document.getElementById("sTelephone");
	patrn = /^1[3,5]\d{9}$/;
	if (!patrn.exec(sTelephone.value)) {
		sTop.innerHTML = "\u8bf7\u8f93\u5165\u624b\u673a\u7684\u6b63\u786e\u683c\u5f0f";
		return false;
	}
	//邮箱
	var sEmail = document.getElementById("sEmail");
	patrn = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	if (!patrn.exec(sEmail.value)) {
		sTop.innerHTML = "\u8bf7\u8f93\u5165\u90ae\u7bb1\u7684\u6b63\u786e\u683c\u5f0f";
		return false;
	}
	//固定电话
	var sFixed = document.getElementById("sFixed");
	patrn = /^0\d{3}\d?-\d{7}\d?/;
	if (!patrn.exec(sFixed.value)) {
		sTop.innerHTML = "\u8bf7\u8f93\u5165\u56fa\u5b9a\u7535\u8bdd\u7684\u6b63\u786e\u683c\u5f0f";
		return false;
	}
	return true;
}
function checkTeacher() {
	var sTop = document.getElementById("inforTip");
	//职称
	var tTitle = document.getElementById("tTitle");
	if (tTitle.value == "" || tTitle.value == null) {
		sTop.innerHTML = "\u804c\u79f0\u4e0d\u80fd\u4e3a\u7a7a";
		return false;
	}
	//研究方向
	var reaserch = document.getElementById("reaserch");
	if (reaserch.value == "" || reaserch.value == null) {
		sTop.innerHTML = "\u7814\u7a76\u65b9\u5411\u4e0d\u80fd\u4e3a\u7a7a";
		return false;
	}
	//手机
	var tTelephone = document.getElementById("tTelephone");
	patrn = /^1[3,5]\d{9}$/;
	if (!patrn.exec(tTelephone.value)) {
		sTop.innerHTML = "\u8bf7\u8f93\u5165\u624b\u673a\u7684\u6b63\u786e\u683c\u5f0f";
		return false;
	}
	//邮箱
	var tEmail = document.getElementById("tEmail");
	patrn = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	if (!patrn.exec(tEmail.value)) {
		sTop.innerHTML = "\u8bf7\u8f93\u5165\u90ae\u7bb1\u7684\u6b63\u786e\u683c\u5f0f";
		return false;
	}
	//固定电话
	var tFixed = document.getElementById("tFixed");
	patrn = /^0\d{3}\d?-\d{7}\d?/;
	if (!patrn.exec(tFixed.value)) {
		sTop.innerHTML = "\u8bf7\u8f93\u5165\u56fa\u5b9a\u7535\u8bdd\u7684\u6b63\u786e\u683c\u5f0f";
		return false;
	}
	return true;
}

